package com.nepenthe.view;

import com.nepenthe.Utils.UserGuiUtils;
import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;
import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI;

import javax.swing.*;
import java.awt.*;

/**
 * @author goodsir
 */
public class index {

    /**
     * 窗体基础设置
     */
    public void indexInit() {
        JFrame jFrame = UserGuiUtils.userGuiInit();
        //初始化--往窗体里放其他控件
        init(jFrame);
        //设置窗体可见
        jFrame.setVisible(true);
    }

    public void init(JFrame jFrame) {
        JPanel titlePanel = new JPanel();
        titlePanel.setLayout(new FlowLayout());
        titlePanel.add(new JLabel("203764赵鑫洋"));
        JLabel image = new JLabel(new ImageIcon("src/main/resources/img/image.jpg"));
        image.setBounds(0, 20, 100, 100);
        jFrame.add(image, "Center");
        jFrame.getContentPane().add(titlePanel, "North");

        //按钮+按钮容器
        JPanel buttons = new JPanel();
        JButton loginBtn = new JButton("登录");
        loginBtn.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
        JButton registerBtn = new JButton("注册");
        registerBtn.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
        buttons.add(loginBtn);

        //登录事件
        loginBtn.addActionListener(e -> {
            jFrame.dispose();
            new login().loginInit();
        });

        //注册事件
        buttons.add(registerBtn);
        registerBtn.addActionListener(e -> {
            jFrame.dispose();
            new register().registerInit();
        });

        jFrame.getContentPane().add(buttons, "South");
        jFrame.setVisible(true);

    }

    public static void main(String[] args) {
        try {
            BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.translucencySmallShadow;
            UIManager.put("RootPane.setupButtonVisible", false);
            org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
        } catch (Exception e) {
            System.out.println("美化失败");
        }
        new index().indexInit();

    }

}
